﻿<cfsilent>
	<cfscript>
		
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		event.setArg("pageTitle", "教学运行基础数据 - 学生学籍管理 - 提前毕业学生管理");
		
		currentTab = event.getArg("TabID","labHistory");
		
		sql = "SELECT s.stu_id,
					   s.sbj_direction,
					   a.sbj_id,
					   s.stu_name,
					   a.cls_name,
					   a.grade,
					   c.sbj_name
				FROM t_student s 
					 INNER JOIN t_student_status b ON b.stu_id = s.stu_id
					 INNER JOIN t_class a ON a.cls_id = s.cls_id 
					 INNER JOIN t_subject c ON c.sbj_id = a.sbj_id 
				WHERE 
					  SUBSTR(b.student_prop,13,1)='1'";
					  
		queryObj = new query( datasource=application.dnsSlave);
		
		rs_historyLeadGraduate = queryObj.execute( sql=sql ).getResult();
		
		studentId = event.getArg("STU");
		
		sql = "SELECT 
					s.stu_id, 
					s.stu_name, 
					a.sbj_id,
					a.cls_name,
					s.sbj_direction,
					c.sbj_name,
					a.grade
					FROM t_student s 
						 INNER JOIN t_class a ON a.cls_id = s.cls_id 
						 INNER JOIN t_subject c ON c.sbj_id = a.sbj_id
					WHERE 
						s.stu_id = :studentId ";
					
		queryObj = new query( datasource=application.dnsSlave);
		queryObj.addParam( name="studentId", value=studentId , cfsqltype="cf_sql_varchar" );
		
		rs_studentEntity = queryObj.execute( sql=sql ).getResult();
		
		passArgs = StructNew();
		
		keyword = event.getArg("Keywords");
		rs_student = queryNew("stu_id");
		
		if ( len(keyword) ) {
		
			sql = "SELECT 
					s.stu_id, 
					s.stu_name, 
					a.cls_name, 
					b.student_prop
					FROM t_student s 
						 INNER JOIN t_class a ON a.cls_id = s.cls_id 
						 INNER JOIN t_student_status b ON b.stu_id = s.stu_id
					WHERE 
						s.stu_id LIKE :condition 
						OR 
						s.stu_name LIKE :condition 
						AND
							SUBSTR(b.student_prop,13,1) != '1'
					ORDER BY s.stu_name";
					
			queryObj = new query( datasource=application.dnsSlave,maxRows = 60 );
			queryObj.addParam( name="condition", value=keyword&"%" , cfsqltype="cf_sql_varchar" );
			
			rs_student = queryObj.execute( sql=sql ).getResult();
			
		}
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('studentProfile')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">学籍档案</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>提前毕业
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
			
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labHistory">class="active"</cfif> id="labHistory" tabTarget="History">提前毕业学生名单</span>
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">新增提前毕业学生</span>
						<cfif len(studentId)>
                        	<span <cfif currentTab eq "labAddLeadGraduate">class="active"</cfif> id="labAddLeadGraduate" tabTarget="AddLeadGraduate">更改学籍</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="History" class="tabContent">
					
					<div class="noticeBlock">
						<div class="operation">
							<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('studentEarlyGraduateDownloadExcel', passArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载本校提前毕业学生名单</span></a>
						</div>
						<h3>本校提前毕业学生名单</h3>
						<hr/>
					</div>
					
					<cfif rs_historyLeadGraduate.recordCount>
						
						<cfset row = 0 />
						<table class="UIEditable">
							<thead>
								<tr>
									<td width="20"></td>
									<td>学号</td>
									<td>姓名</td>
                                    <td>班级</td>
                                    <td>年级</td>
									<td>修读专业</td>
                                    <td>专业方向</td>
                                    <td></td>
								</tr>
							</thead>
							<tbody>
                            <cfloop query="rs_historyLeadGraduate" >
                            	<cfset structInsert(passArgs,"STU",rs_historyLeadGraduate.stu_id,true)/>
                                <cfset structInsert(passArgs,"studentID",rs_historyLeadGraduate.stu_id,true)/>
                                <cfif rs_historyLeadGraduate.sbj_direction eq '0'>
									<cfset SubjectDirectionName = "无" />
                                <cfelse>
                                    <cfset SubjectDirectionName = "" />
                                    <cfset DirID = rs_historyLeadGraduate.sbj_id />
                                    <cfset DirID = DirID & rs_historyLeadGraduate.sbj_direction />
                                    
                                    <cfset sql = "SELECT a.sbj_name 
												FROM t_subject a 
												WHERE a.sbj_id = :DirID "/>
                                            
									<cfset queryObj = new query( datasource=application.dnsSlave)/>
                                    <cfset queryObj.addParam( name="DirID", value=DirID , cfsqltype="cf_sql_varchar" )/>
                                    <cfset rs_sbjName = queryObj.execute( sql=sql ).getResult()/>
                                    
                                    <cfif rs_sbjName.recordCount GT 0>
                                        <cfset SubjectDirectionName = rs_sbjName.sbj_name />
                                    </cfif>
                                </cfif>
								<cfset row ++ />
								<tr class="editRows">
								    <td class="index"><cfoutput>#row#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_historyLeadGraduate.stu_id#</cfoutput></span></td>
									<td><cfoutput>#rs_historyLeadGraduate.stu_name#</cfoutput></td>
									<td><cfoutput>#rs_historyLeadGraduate.cls_name#</cfoutput></td>
									<td><cfoutput>#rs_historyLeadGraduate.grade#</cfoutput></td>
									<td><cfoutput>#rs_historyLeadGraduate.sbj_name#</cfoutput></td>
                                    <td><cfoutput>#SubjectDirectionName#</cfoutput></td>
                                    <td><a href="<cfoutput>#BuildURL('studentProfileView',passArgs)#</cfoutput>" class="stat details" title="查看学籍"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="<cfoutput>#BuildURL('studentEarlyGraduateRemoveDo',passArgs)#</cfoutput>" class="stat remove" title="取消资格"></a></td>
								</tr>
							</cfloop>
						    </tbody>
						</table>
						<cfelse>
							<div class="systemNotice">
								<p>目前没有提前毕业学生记录</p>
							</div>
					 </cfif>
				</div>

				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('studentLeadGraduate')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						
						<div class="label">
							<b>学号或姓名</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_student.recordCount>

						<div class="clearfix">
							<div class="UICardTable">
                                <cfloop query="rs_student" >
									
									<cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
                                    <cfset structInsert(passArgs,"TabID","labAddLeadGraduate",true) />
									<cfset propertyAdvice.parseProperty(rs_student.student_prop) />
									
									<dl <cfif not propertyAdvice.getInSchool()>class="disabled"</cfif>>
										<dt>
											<a href="<cfoutput>#buildURL('studentLeadGraduate', passArgs)#</cfoutput>">
												<em class="people"><!--imgholder--></em>
												<dd>
													<h3><cfoutput>#rs_student.stu_name#</cfoutput> - <cfoutput>#rs_student.cls_name#</cfoutput></h3>
													<p><cfoutput>#rs_student.stu_id#</cfoutput></p>
												</dd>
											</a>
										</dt>
									</dl>
								</cfloop>					
							</div>
						</div>
						<cfelse>
							<cfif len(keyword)>
								<div class="systemNotice">
									<p>没有搜索到该学生记录或该学生已授予辅修</p>
								</div>
							</cfif>
					</cfif>
					
				</div>
				

				<cfif len(studentId)>
					
					<div id="AddLeadGraduate" class="tabContent">
				
						<div class="noticeBlock">
							<h3>即将授权提前毕业学生信息</h3>
							<hr>
						</div>
						<cfif rs_studentEntity.sbj_direction eq '0'>
							<cfset SubjectDirectionName = "无" />
                        <cfelse>
                        	<cfset SubjectDirectionName = "" />
                            <cfset DirID = rs_studentEntity.sbj_id />
                            <cfset DirID = DirID & rs_studentEntity.sbj_direction />
                            <cfset sql = "SELECT a.sbj_name 
											FROM t_subject a 
											WHERE a.sbj_id = :DirID "/>
                                            
                            <cfset queryObj = new query( datasource=application.dnsSlave)/>
                            <cfset queryObj.addParam( name="DirID", value=DirID , cfsqltype="cf_sql_varchar" )/>
                            <cfset rs_Dir = queryObj.execute( sql=sql ).getResult()/>
                            <cfif rs_Dir.recordCount GT 0>
                            	<cfset SubjectDirectionName = rs_Dir.sbj_name />
                            </cfif>
						</cfif>
						<table class="UItable withBorder">
							<tbody>
								<tr>
									<td>学号</td>
									<td><span class="number"><cfoutput>#rs_studentEntity.stu_id#</cfoutput></span></td>
									<td>姓名</td>
									<td><cfoutput>#rs_studentEntity.stu_name#</cfoutput></td>
									<td>主修专业</td>
									<td><cfoutput>#rs_studentEntity.sbj_name#</cfoutput></td>
								</tr>
                                <tr>
									<td>年级</td>
									<td><span class="number"><cfoutput>#rs_studentEntity.grade#</cfoutput></span></td>
									<td>行政班</td>
									<td><cfoutput>#rs_studentEntity.cls_name#</cfoutput></td>
									<td>专业方向</td>
									<td><cfoutput><cfif rs_studentEntity.sbj_direction eq 0>无<cfelse>#SubjectDirectionName#</cfif></cfoutput></td>
								</tr>
							</tbody>
						</table>
					
						<form id="formSign" onsubmit="javascript:return processVerfiyForm('formSign');" class="formWrapper Transparent" method="post" action="<cfoutput>#BuildURL('studentEarlyGraduateAddDo')#</cfoutput>">
							<input type="hidden" name="STU" value="<cfoutput>#studentId#</cfoutput>" />
							<div class="lable">
								<input class="button" type="submit" value="授权" />
							</div>
						</form>
					</div>
					
				</cfif>

				
				
				
			
			</div>
		</li>
	</ul>
</div>